# Contributor: Antoine Martin (ayakael) <dev@ayakael.net>
# Maintainer: Antoine Martin (ayakael) <dev@ayakael.net>
pkgname=py3-django-q2
_pyname="django-q2"
pkgver=1.7.3
pkgrel=0
arch="noarch"
pkgdesc="A multiprocessing distributed task queue for Django"
url="https://pypi.python.org/project/django-q2"
license="MIT"
depends="
	py3-asgiref
	py3-blessed
	py3-dateutil
	py3-django
	py3-django-picklefield
	py3-django-redis
	py3-future
	py3-tz
	py3-redis
	py3-six
	py3-sqlparse
	py3-wcwidth
	"
makedepends="
	py3-gpep517
	py3-wheel
	py3-poetry-core
	"
checkdepends="
	valkey
	py3-pytest-django
	py3-boto3
	py3-psutil
	py3-mongo
"
source="
	$pkgname-$pkgver.tar.gz::https://github.com/django-q2/django-q2/archive/refs/tags/v$pkgver.tar.gz
	fix-HiredisParser-reference.patch
	"
builddir="$srcdir"/$_pyname-$pkgver
subpackages="$pkgname-pyc"

build() {
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	valkey-server &
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer .dist/*.whl
	# test_qcluster: stalls
	# test_scheduler: requires croniter module
	# test_mongo: reqires setting up mongo server
	# test_max_rss: failure on 32-bit arches
	REDIS_HOST=127.0.0.1 \
	MONGO_HOST=127.0.0.1 \
	.testenv/bin/python3 -m pytest -v -k 'not test_qcluster and not test_scheduler and not test_mongo and not test_max_rss' || FAIL=true
	pkill valkey-server
	if [ "$FAIL" = "true" ]; then
		return 1
	fi
}

package() {
	python3 -m installer -d "$pkgdir" \
		.dist/*.whl
}

sha512sums="
af257e7266d3ace981d58a88aa70c90a79f6382a3ca65feccff35b00d4640e3ec4b341bdeb3546d1a002938b210e8152c9da1ed673b7e0ffcc6dc8647badb511  py3-django-q2-1.7.3.tar.gz
b4df8b946cff0b9160a8dc2a94f7ebbc288c35a4ee956f3f29d7a268f6a769bbc2bfdec6b7bd2e4c7134974820f306d07dfba37aeae2c37b8b9eefb2b3f3e5d4  fix-HiredisParser-reference.patch
"
